package com.kd.juhaowan.ui.holder;

import android.annotation.SuppressLint;
import android.view.View;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.bumptech.glide.Glide;
import com.flyjingfish.shapeimageviewlib.ShapeImageView;
import com.kd.juhaowan.R;
import com.kd.juhaowan.http.model.GiftModel;
import com.kd.juhaowan.ui.adapter.BaseViewHolder;
import com.kd.juhaowan.ui.listener.OnItemClickListener;
import com.kd.juhaowan.ui.listener.OnItemDianzanListener;
import com.kd.juhaowan.utils.GlideHelper;


import butterknife.BindView;
import butterknife.OnClick;

public class Fuli648ViewHolder extends BaseViewHolder {



    @BindView(R.id.item_image)
    ShapeImageView imageView;

    @BindView(R.id.item_game_name)
    TextView nameView;

    @BindView(R.id.item_game_zhekou)
    TextView zhekouView;

    @BindView(R.id.item_game_sheyu)
    TextView shengyuView;

    @BindView(R.id.item_lingqu)
    TextView lingquView;

    private GiftModel mModel;
    @OnClick(R.id.item_lingqu)
    public void onLingquclick(){
        if(mModel.getIs_receive()!=0)
            return;
        OnItemClickListener listener = getOnItemClickListener();
        if(listener instanceof OnItemDianzanListener){
            ((OnItemDianzanListener) listener).onItemDianzanClick(this,getLayoutPosition());
        }
    }




    public Fuli648ViewHolder(@NonNull View itemView) {
        super(itemView);
    }



    @SuppressLint("ResourceType")
    public void setDate(GiftModel model){
        mModel = model;
        GlideHelper.loadGoodsCover(Glide.with(getItemView()),imageView,model.getGame_logo());
        nameView.setText(model.getGame_name());
        if(model.getGame_discount()>0){
            zhekouView.setVisibility(View.VISIBLE);
            zhekouView.setText(model.getName());
        }else{
            zhekouView.setVisibility(View.INVISIBLE);
        }
        shengyuView.setText("剩余"+model.getResidue_number());

        if(model.getIs_receive()==0){
            lingquView.setText("领取");
            lingquView.setBackgroundResource(R.drawable.login_small_btn);
            lingquView.setTextColor(getContext().getColor(R.color.white));
        }else {
            lingquView.setText("已领取");
            lingquView.setTextColor(getContext().getColor(R.color.c60));
            lingquView.setBackgroundResource(R.drawable.gift_btn_recived);
        }


    }


}
